<template>
  <j-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :maskClosable="false"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel">
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="仓库">
              <j-dict-select-tag placeholder="请选择仓库" v-model="queryParam.wareHouseId" dictCode="erp_warehouse,name,id"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="库位编号">
              <a-input placeholder="请输入库位编号" v-model="queryParam.code"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="库位名称">
                <a-input placeholder="请输入库位名称" v-model="queryParam.name"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="状态">
                <j-dict-select-tag placeholder="请选择状态" v-model="queryParam.status" dictCode="erp_status"/>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">

    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys,onChange: onSelectChange,type: 'radio'}"
        class="j-table-force-nowrap"
        @change="handleTableChange">


      </a-table>
    </div>


  </a-card>
  </j-modal>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'ErpLocationList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {

    },
    data () {
      return {
        title:'',
        disableMixinCreated: true,
        width:800,
        visible: false,
        disableSubmit: false,
        description: '库位表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'仓库编号',
            align:"center",
            dataIndex: 'warehouseCode'
          },
          {
            title:'仓库名称',
            align:"center",
            dataIndex: 'warehouseName'
          },
          {
            title:'库位编号',
            align:"center",
            dataIndex: 'code'
          },
          {
            title:'库位名称',
            align:"center",
            dataIndex: 'name'
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'status_dictText',
            scopedSlots: { customRender: 'status' }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],statusColorMap: {
          '启用': 'green',
          '停用': 'red'
        },
        url: {
          list: "/base/erpLocation/list",
          delete: "/base/erpLocation/delete",
          deleteBatch: "/base/erpLocation/deleteBatch",
          exportXlsUrl: "/base/erpLocation/exportXls",
          importExcelUrl: "base/erpLocation/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      add() {
        this.showModal();
      },
      showModal() {
        this.visible = true;
        this.queryParam = { procurementType: this.procurementType }
        this.loadData();
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        // fieldList.push({type:'string',value:'wareHouseId',text:'仓库',dictCode:"erp_warehouse,name,id"})
        fieldList.push({type:'string',value:'code',text:'库位编号',dictCode:''})
        fieldList.push({type:'string',value:'name',text:'库位名称',dictCode:''})
        fieldList.push({type:'string',value:'status',text:'状态',dictCode:'erp_status'})
        this.superFieldList = fieldList
      },
      handleCancel () {
        this.close()
      },
      handleOk () {
        this.$emit('handlerOk',this.selectionRows[0]);
        this.close();
        // console.log(this.selectionRows[0])
      },
      close() {
        // this.searchReset(false);
        this.queryParam = {}
        this.selectedRowKeys = []
        this.selectionRows = []
        this.visible = false;
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>